<!DOCTYPE html>
<html class="x-admin-sm">
    <head>
        <meta charset="UTF-8">
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <link rel="stylesheet" href="<?php echo __ACSS__;?>/font.css">
        <link rel="stylesheet" href="<?php echo __ACSS__;?>/xadmin.css">
        <!-- <link rel="stylesheet" href="./css/theme5.css"> -->
        <script src="<?php echo __ALIB__;?>/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="<?php echo __AJS__;?>/xadmin.js"></script>
        <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
        <!--[if lt IE 9]>
        <script src="<?php echo __AJS__;?>/html5.min.js"></script>
        <script src="<?php echo __AJS__;?>/respond.min.js"></script>
        <![endif]-->
    </head>
    <body>
        <div class="x-nav">
          <span class="layui-breadcrumb">
            <a>首页</a>
            <a>
              <cite>权限分类</cite></a>
          </span>
          <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
            <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
        </div>
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-header">
                            <button class="layui-btn layui-btn-danger" onclick="xadmin.open('新增分类','/index.php/admin/adminCate/cateAdd',400,230)"><i class="layui-icon"></i>新增分类</button>
                        </div>
                        <div class="layui-card-body ">
                            <table class="layui-table layui-form">
                                <thead>
                                  <tr>
                                    <th>ID</th>
                                    <th>分类名</th>
                                    <th>操作</th>
                                </thead>
                                <tbody>

                                  <?php foreach($res as $v){ ?>
                                      <tr>
                                        <td><?php echo $v['id']; ?></td>
                                        <td><?php echo $v['title']; ?></td>
                                        <td class="td-manage">
                                            <button class="layui-btn layui-btn-warm layui-btn-xs"  onclick="xadmin.open('编辑分类','<?php echo '/index.php/admin/adminCate/cateEdit?id='.$v['id']; ?>',400,230)" ><i class="layui-icon">&#xe642;</i>编辑</button>
                                            <button class="layui-btn-danger layui-btn layui-btn-xs"  onclick="member_del(<?php echo $v['id']; ?>)" href="javascript:;" ><i class="layui-icon">&#xe640;</i>删除</button>
                                          </a>
                                        </td>
                                      </tr>
                                  <?php } ?>

                                </tbody>
                              </table>
                        </div>
                        <div class="layui-card-body ">
                            <div class="page">
                                <div>
                                    <a class="prev <?php if($page==1) echo 'layui-disabled';?>" href="/index.php/admin/adminCate/cateList?page=1">&lt;&lt;&lt;</a>
                                    <?php foreach($pages[0] as $k=>$v){ if($k==$page){ echo '<span class="current layui-disabled">'.$k.'</span>'; }else{ ?>
                                    <a class="num" href="/index.php/admin/adminCate/cateList?<?php echo $v; ?>"><?php echo $k; ?></a>
                                    <?php } } ?>
                                    <a class="prev <?php if($page==$pages[1] || $pages[1]==1) echo 'layui-disabled';?>" href="/index.php/admin/adminCate/cateList?page=<?php echo $pages[1];?>">&gt;&gt;&gt;</a>
                                    <label>&emsp;共 <?php echo $num;?> 条</label>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div> 
    </body>
    <script>
      layui.use(['laydate','form'], function(){
        var laydate = layui.laydate;
        var form = layui.form;
        
        //执行一个laydate实例
        laydate.render({
          elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
          elem: '#end' //指定元素
        });
      });


      /*用户-删除*/
      function member_del(id){
          layer.confirm('确认要删除吗？',function(){
              //异步删除
              $.post("/index.php/admin/adminCate/cateDel",{id:id}, function (res) {
                  res = JSON.parse(res);
                  if (res.code==500){
                      layer.alert(res.data, {
                          icon: 5
                      })
                  }else{
                      layer.msg(res.data,{icon:1,time:1000});
                      // 对父窗口进行刷新
                      window.setTimeout("xadmin.father_reload()",1000);
                  }
              });
          });
      }


    </script>
</html>